package cn.edu.Day11;


import java.io.*;

//管道输出流
public class PipedOutput implements Runnable {
    File descFile;

    PipedInputStream pis;
    public PipedOutput(File descFile) {
        this.descFile = descFile;
        pis = new PipedInputStream();

    }
    public PipedInputStream getInputStream(){
        return this.pis;
    }

    public void run() {
        try {
            OutputStream os = new FileOutputStream(descFile);
            int len = -1;
            byte bs [] = new byte[1024];
            while((len=pis.read(bs))!=-1){
                os.write(bs,0,len);//将文件获取的内容写出去
            }
            os.close();
            pis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
